/*******************************************************************************
 * Copyright (c) 2010, 2030 www.mahao.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.itlaobing.eshopmanagement.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.itlaobing.eshopmanagement.entity.Area;
import cn.itlaobing.eshopmanagement.mapper.AreaMapper;
import cn.itlaobing.eshopmanagement.service.AreaService;

/** 
 * ClassName: AreaServiceImpl <br/> 
 * Function: TODO 功能描述 <br/> 
 * date: 2017年5月23日 上午9:49:07 <br/> 
 * 
 * @author Mmmmm 
 * @version  
 * @since JDK 1.8 
 */
@Service
public class AreaServiceImpl implements AreaService {
	
	@Autowired
	private AreaMapper areaMapper;
	
	@Override
	public List<Area> selectWithPage(Map<String, String> searchFilter) {
		if(searchFilter == null){
			searchFilter = new HashMap<>();
		}
		if(searchFilter.get("pageNum") == null){
			searchFilter.put("pageNum", "1");
		}
		if(searchFilter.get("pageSize") == null){
			searchFilter.put("pageSize", "5");
		}
		return areaMapper.selectWithPage(searchFilter);
	}

	
	@Override
	public Area selectById(Long id) {
		
		return areaMapper.selectByPrimaryKey(id);
	}

	@Override
	public int update(Area area) {
		return areaMapper.updateByPrimaryKeySelective(area);
	}

	@Override
	public int addArea(Area area) {
		return areaMapper.insertSelective(area);
	}


	@Override
	public Integer deleteById(Long id) {
		Area area = areaMapper.selectByPrimaryKey(id);
		if(area==null){
			return null;
		}
		return areaMapper.deleteByPrimaryKey(id);
	}

}
